package com.hsr.web.controller;


import com.hsr.web.dto.ArticleCategoryDTO;
import com.hsr.web.dto.ArticleQuery;
import com.hsr.web.entity.TArticleCategory;
import com.hsr.web.service.ITArticleCategoryService;
import com.hsr.web.utils.ResultVOUtil;
import com.hsr.web.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tb
 * @since 2022-05-10
 */
@RestController
@Api(tags = "文章分类相关接口")
@RequestMapping("/category")
public class TArticleCategoryController {

    @Autowired
    ITArticleCategoryService itArticleCategoryService;

    @GetMapping("/list")
    @ApiOperation("查询")
    public ResultVO list() {
        return ResultVOUtil.success(itArticleCategoryService.list());
    }

    @PutMapping("/{id}")
    @ApiOperation("编辑")
    public ResultVO update(@RequestBody ArticleCategoryDTO categoryDTO, @PathVariable Integer id){
        TArticleCategory category = new TArticleCategory();
        category.setId(id);
        BeanUtils.copyProperties(categoryDTO,category);
        itArticleCategoryService.updateById(category);
        return ResultVOUtil.success();
    }

}
